package com.example.hp.yuejian5.model;


import com.example.hp.yuejian5.RetrofitListener.RetrofitListener;
import com.example.hp.yuejian5.bean.AttentionBean;
import com.example.hp.yuejian5.service.CancelAttentionMasterService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

import static com.example.hp.yuejian5.other.url.INDEXURL;

public class CancelAttentionMasterModel {
    private Retrofit retrofit;
    private CancelAttentionMasterService cancelAttentionMasterService;

    public CancelAttentionMasterModel()
    {
        retrofit=new Retrofit.Builder()
                .baseUrl(INDEXURL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        cancelAttentionMasterService=retrofit.create(CancelAttentionMasterService.class);
    }

    public void cancelAttentionMaster(String user_id, String master_id , final RetrofitListener listener)
    {
        Call<AttentionBean> call=cancelAttentionMasterService.cancelAttentionMaster(user_id, master_id);
        call.enqueue(new Callback<AttentionBean>() {
            @Override
            public void onResponse(Call<AttentionBean> call, Response<AttentionBean> response) {
                listener.onSuccess(response.body(),1);
            }

            @Override
            public void onFailure(Call<AttentionBean> call, Throwable t) {
                listener.onFail();
            }
        });
    }
}
